using System;
using System.Collections.Specialized;
using System.Xml;
using System.Collections.Generic;

namespace FreeFlow.Client
{
	/// <summary>
	/// A dropdown field.
	/// </summary>
	[Serializable]
	public class DropDownField : Field
	{
    internal DropDownField(Form form, XmlElement fieldNode)
      : base(form, fieldNode)
		{
		}

    private List<string> options = new List<string>();
    /// <summary>
    /// Gets the number of options in the dropdown.
    /// </summary>
    public int OptionCount
    {
      get
      {
        return options.Count;
      }
    }

    /// <summary>
    /// Gets the option at the specified index.
    /// </summary>
    /// <param name="index">Index.</param>
    /// <returns></returns>
    public string Option(int index)
    {
      return options[index];
    }

    internal override void FillValue(XmlElement node)
    {
      base.FillValue(node);
      FillFromOptionList(options, node);
      options.Insert(0, "");
    }
	}
}
